package com.ruiysoft.service.logistics;

import com.alibaba.fastjson.JSON;
import com.ruiysoft.entity.logistics.APIExpressCompany;
import com.ruiysoft.entity.logistics.APILogisticsMessage;
import com.ruiysoft.entity.logistics.ILogisticsConfig;
import com.ruiysoft.entity.logistics.LogisticsException;
import com.ruiysoft.pub.core.Result;

import javax.swing.text.html.Option;
import java.util.List;
import java.util.Optional;

public interface IExpressCaller<T extends ILogisticsConfig> {

    default T parseConfig(String str){
        Object o = JSON.parseObject(str,getConfigClass());
        return (T)o;
    }
    Class getConfigClass();
    String getAPISupplier();
    Optional<List<? extends APIExpressCompany>> queryExpressCompByExpressNO(T iLogisticsConfig, String expressNO)throws LogisticsException;
    Optional<? extends APILogisticsMessage> queryExpress(T iLogisticsConfig, String expressNO, String expressCom) throws LogisticsException;
    Optional<? extends APILogisticsMessage> queryExpress(T iLogisticsConfig, String expressNO)throws LogisticsException;
    /**
     * 用于处理快递回调，先把回调信息放入队列
     * @param shopID
     * @param iLogisticsConfig
     * @param expressNO
     * @param expressCom
     * @return
     */
    Result<String> subscribe(Long shopID,T iLogisticsConfig, String expressNO,String expressCom);
}
